class Solution(object):
    def shortestWay(self, source, target):
        """
        :type source: str
        :type target: str
        :rtype: int
        """
        n = len(source)
        m = len(target)
        index = 0
        total = 0
        while True:
            now_index = index
            for i in range(n):
                if source[i] == target[now_index]:
                    now_index += 1
                    if now_index == m:
                        return total + 1
            total += 1
            if now_index == index:
                return -1
            index = now_index




data = Solution()
source = 'abc'
target = 'abcbc'
print(data.shortestWay(source, target))
source = "abc"
target = "acdbc"
print(data.shortestWay(source, target))
source = "xyz"
target = "xzyxz"
print(data.shortestWay(source, target))